#!/usr/bin/env sh
set -e

die() {
  echo "$@"
  exit 1
}

fmt() {
  ag -g '.go$' | xargs -IC go fmt C
}

run() {
  build
  ./mobsql "$@"
}

test() {
  go test *_test/*.go
}

sf() {
  sqlfluff format --dialect sqlite dbschema/sqlviews/*
}

build() {
  go build -v -tags=sqlite_math_functions cli/mobsql.go
}

if [ -z "$1" ]; then
  build
else
  "$@"
fi